<?php
class ml_biz_atNick_suggestNick {
    
    private $rds;
    private $rdsF;
    private $list;
    
    function __construct(){
        $this->rds = new ml_model_atNick_rds();
    }
    
    public function get_suggest_nick_by_followlist($key, $uid){
        
    
        $this->list = $this->rds->get_atNick_nickbyfollowlist($key, $uid);

        if (!empty($this->list)) {
            $aNicks = ml_tool_nick::uids2nicks($this->list);
            uasort($aNicks, array($this, 'sort_nick_by_latest'));
           
            return $aNicks;
        }
        
        return false;
    }
    
    private function sort_nick_by_latest($a, $b){
        
        for ($i=0; $i<strlen($b); $i++){
            $aa = Tool_string::substr_by_charater($a, $i, 1);
            $aa = ml_tool_chineseSpell::getFullSpell($aa);
            $bb = Tool_string::substr_by_charater($b, $i, 1);
            $bb = ml_tool_chineseSpell::getFullSpell($bb);
            
            if ($aa == '*') {
                return 1;
            } 
            
            if ($bb == '*') {
                return -1;
            } 
            
            
            $result = strnatcasecmp($aa,$bb);
            if ($result !== 0) {
                return $result;
            } 
        }
        
    }
}